package ynu.edu.achitectureclass.Factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import ynu.edu.achitectureclass.entity.*;
import ynu.edu.achitectureclass.service.BaseSensorService;
import ynu.edu.achitectureclass.service.SensorService;

@Service
public class SensorServiceFactory {
    @Autowired
    @Qualifier("air_temp_Service") // 默认使用 Air_temp_Service
    private SensorService<Air_temp> defaultService;

    @Autowired
    @Qualifier("air_temp_Service")
    private SensorService<Air_temp> airTempService;

    @Autowired
    @Qualifier("air_water_Service")
    private SensorService<Air_water> airWaterService;

    @Autowired
    @Qualifier("soil_L_Service")
    private SensorService<Soil_L> soilLService;

    @Autowired
    @Qualifier("soil_N_Service")
    private SensorService<Soil_N> soilNService;

    @Autowired
    @Qualifier("soil_K_Service")
    private SensorService<Soil_K> soilKService;

    @Autowired
    @Qualifier("soilTemperatureService")
    private SensorService<SoilTemperature> soilTemperatureSensorService;

    @Autowired
    @Qualifier("soilWaterService")
    private SensorService<SoilWater> soilWaterService;


    // 其他 service...

    public SensorService<?> getService(String sensorType) {
        switch (sensorType) {
            case "Air_temp":
                return airTempService;
            case "Air_water":
                return airWaterService;
            case "Soil_L":
                return soilLService;
            case "Soil_K":
                return soilKService;
            case "Soil_N":
                return soilNService;
            case "SoilTemperature":
                return soilTemperatureSensorService;
            case "SoilWater":
                return soilWaterService;
            // 其他 case...
            default:
                throw new IllegalArgumentException("Unknown sensor type: " + sensorType);
        }
    }
    public String getAccessToken() {

        return defaultService.getAccessToken();
    }
}